mui.init();
//保存司机


function save(){
	var sessionId=(plus.navigator.getCookie("sessionId")==null)?"":plus.navigator.getCookie("sessionId");
	var drivername = $("#drivername").val();
	var driverphone = $("#driverphone").val();
	var tracknumber = $("#tracknumber").val();
	if(drivername==""||driverphone==""||tracknumber==""){
			$("#doc-vld-msg").submit();
			return false;
	}else{
		if(driverphone.length!=11||tracknumber.length!=7){
			$("#doc-vld-msg").submit();
			return false;
		}else{
			var id = "body-loading";
  	$(window).loading({action:"open",id:id,font:40}); 
	mui.getJSON ("json/locat.json", function (data) {
			var  locat=data["url"];
				var factoryid=data["factoryid"];
			var factoryId=(plus.navigator.getCookie("factoryid")==null)?"":plus.navigator.getCookie("factoryid");
					if(factoryId != factoryid)
					window.location.href="login.html";
	        mui.ajax(locat+"/clientUser/saveDriver?sessionId="+sessionId, {
	            type: "POST",
	            data: {
	                drivername: drivername,
	                driverphone: driverphone,
	                tracknumber: tracknumber
	            },
	            success: function(data, status, xhr) {
	            		var time = setTimeout(function(){
			   				//关闭
			   				$(window).loading({action:"close",id:id});
			   			},100);
						if("success" == data["msg"]){
								swal("Good","新增成功","success");
								window.location.href="tjsj.html";
						}
	            },
	            error:function(data){
	            	var time = setTimeout(function(){
			   				//关闭
			   				$(window).loading({action:"close",id:id});
			   			},100);
	            	plus.ui.toast("","服务异常！","error");
	            	window.location.href=login.html;
	            }
	        });
    });  
		}
		
	}
	



}
